/**
* @file Network.TP.h
*
* @ingroup	libNetwork
* @brief	structures for transport layer
*			
* @author	Andreas Schlueter <mersaultpatrice@gmail.com>
* @date	Oct 2008
* @version	0.5
*/

#ifndef NETWORK_TP_H
#define NETWORK_TP_H

#include <stdint.h>

#define	TP_HEADER_SIZE	2		///< size of transport header	
#define PAYLOAD_SIZE    110     ///< size of a segment payload

/**
 * @brief defines the frame of a data record
 */
enum segment_type{
	FIRST_SEGMENT = 0,
	MIDDLE_SEGMENT = 0xF0,
	LAST_SEGMENT = 0xFF
};


/**
* (16bit) key identifies a data packet
* 
* @NOTE  start address of structure must be even!
*/
typedef union{
	uint16_t raw;
	struct{
		uint16_t  sequence_nr:10;   ///< msg identifier
		uint16_t  source_id  : 6;   ///< network id of msg originator
	}decoded;
}segment_key_t;

/**
* memory data segment
*/ 
typedef struct{
	segment_key_t	key;				///< segment key (asure even address!)
	uint8_t			data[PAYLOAD_SIZE];	///< segment data
}segment_t;


#endif
